import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsEnum, IsUUID, IsString } from 'class-validator';
import { NotificationType, SourceType } from '../../../entities/notification.entity';

/**
 * 创建通知DTO
 */
export class CreateNotificationDto {
  @ApiProperty({
    description: '通知标题',
    example: '任务已分配给您',
  })
  @IsNotEmpty({ message: '通知标题不能为空' })
  @IsString({ message: '通知标题必须是字符串' })
  title: string;

  @ApiProperty({
    description: '通知内容',
    example: '您有一个新的任务需要处理：[网站重构] - 首页设计',
  })
  @IsNotEmpty({ message: '通知内容不能为空' })
  @IsString({ message: '通知内容必须是字符串' })
  content: string;

  @ApiProperty({
    description: '通知类型',
    enum: NotificationType,
    example: NotificationType.TASK_ASSIGNMENT,
  })
  @IsNotEmpty({ message: '通知类型不能为空' })
  @IsEnum(NotificationType, { message: '无效的通知类型' })
  type: NotificationType;

  @ApiProperty({
    description: '接收通知的用户ID',
    example: 'd290f1ee-6c54-4b01-90e6-d701748f0851',
  })
  @IsNotEmpty({ message: '用户ID不能为空' })
  @IsUUID('4', { message: '用户ID必须是有效的UUID' })
  userId: string;

  @ApiProperty({
    description: '触发通知的源对象ID',
    example: 'd290f1ee-6c54-4b01-90e6-d701748f0851',
  })
  @IsNotEmpty({ message: '源对象ID不能为空' })
  @IsUUID('4', { message: '源对象ID必须是有效的UUID' })
  sourceId: string;

  @ApiProperty({
    description: '源对象类型',
    enum: SourceType,
    example: SourceType.TASK,
  })
  @IsNotEmpty({ message: '源对象类型不能为空' })
  @IsEnum(SourceType, { message: '无效的源对象类型' })
  sourceType: SourceType;
} 